<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>管理后台——登陆</title>
	<?php include(APPLICATION_BASE_TPL_PATH . "/inc/include.phtml"); ?>
</head>
<body>
<!-- 顶栏 -->
<div class="container">
	<div class="row">
		<div class="col-md-4 col-md-offset-4">
			<div class="panel panel-primary" id="login-panel">
				<div class="panel-heading center">
                    <h2 class="panel-title">登陆信息</h2>
                </div>
                <div class="panel-body">
                    <fieldset>
                        <div class="form-group">
                            <i class="fa fa-user fa-fw input-img"></i>
                            <input class="form-control pad-left" placeholder="用户名" name="username" id="username" type="text" autofocus>
                        </div>
                        <div class="form-group">
                            <i class="fa fa-key fa-fw input-img2"></i>
                            <input class="form-control pad-left" name="password" placeholder="密码" id="password" type="password" value="">
                        </div>
                        <input type="button" id="login" class="btn btn-lg btn-primary btn-block" value="登陆">
                        <div><span class="tips" id="tip"></span></div>
                    </fieldset>
                </div>
			</div>
		</div>
	</div>
</div>
<script>
$(document).ready(function(){
    $("body").keydown(function(e){
        if(e.keyCode == 13) {
            $('#login').click();
        }
    });
    $('#login').click(function(){
        if(isNull("用户名","username"))  {return;}
        if(isNull("密码","password"))  {return;}
        $.post("<?php echo APP_ADMIN_PATH; ?>/login/login", {
            username:$('#username').val(),
            password:$('#password').val()
        },
        function(data){
            if(data.retcode == 2000000) {
                $('#tip').html("登陆成功 正在跳转...");
                <?php if($refer) { ?>
                jumpUrl('<?php echo $refer; ?>');
                <?php } else { ?>
                jumpUrl('<?php echo APP_ADMIN_PATH; ?>/welcome/index');
                <?php } ?>
            } else {
                $('#tip').html(data.msg);
            }
        },"json");
    });
});

//空验证
function isNull(col,id){
    var tip = null;
    var value = document.getElementById(id).value;
    if(value==""||value==null){
        $('#tip').html("请填写"+col);
        $('#'+id).focus();
        return 1;
    }else{
        return 0;
    }
}
</script>
</body>
</html>
